<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>动态菜单</title>
  <script>
    //当所有的网页加载完成之后才执行function的函数
    window.onload = function() {
      //找到了10个dl
      let dls = document.querySelectorAll("#nav dl")
      for(let i=0;i<dls.length;i++) {
        let dl = dls[i];
        //鼠标移动进去之后的函数
        dl.onmouseover = function() {
          //this此时表示自己
          let dds = this.querySelectorAll("dd");
          // alert(dds.length)
          dds.forEach(function(e){
            e.style.display = 'block';
          })
        }
        dl.onmouseleave = function() {
          let dds = this.querySelectorAll("dd");
          dds.forEach(e=>{
            e.style.display='none';
          })
        }
      }
    }
  </script>
  <style>
    *{
      margin:0px;
      padding:0px;
      font-size:14px;
    }
    *.clear {
      clear: both;
    }
    #nav {
      width: 1200px;
      margin:auto;
    }
    #nav li {
      list-style: none;
    }
    li.nav_li {
      float:left;
      width: 118px;
    }
    li.nav_li dd {
      height:40px;
      background: #393;
      color:#fff;
      border-right:1px solid #fff;
      border-bottom:1px solid #fff;
      display: none;
    }
    li.nav_li dd:hover {
      background: #399; 
      cursor: pointer;
    }
    li.nav_li dt {
      height:40px;
      background: #933;
      color:#fff;
      border-right:1px solid #fff;
    }
    li.nav_li dt span,li.nav_li dd span {
      position: relative;
      left:32px;
      top:8px;
    }
    li.nav_li dd span {
      left:16px;
    }
  </style>
</head>
<body>
  <ul id="nav">
    <li class="nav_li">
      <dl>
        <dt><span>网站首页</span></dt>
        <dd><span>导航目录01</span></dd>
        <dd><span>导航目录02</span></dd>
        <dd><span>导航目录03</span></dd>
        <dd><span>导航目录04</span></dd>
        <dd><span>导航目录05</span></dd>
        <dd><span>导航目录06</span></dd>
      </dl>
    </li>
    <li class="nav_li">
      <dl>
        <dt><span>教学机构</span></dt>
        <dd><span>导航目录01</span></dd>
        <dd><span>导航目录02</span></dd>
        <dd><span>导航目录03</span></dd>
        <dd><span>导航目录04</span></dd>
        <dd><span>导航目录05</span></dd>
        <dd><span>导航目录08</span></dd>
        <dd><span>导航目录08</span></dd>
        <dd><span>导航目录08</span></dd>
        <dd><span>导航目录08</span></dd>
      </dl>
    </li>
    <li class="nav_li">
      <dl>
        <dt><span>招生就业</span></dt>
        <dd><span>导航目录01</span></dd>
        <dd><span>导航目录02</span></dd>
        <dd><span>导航目录03</span></dd>
        <dd><span>导航目录04</span></dd>
        <dd><span>导航目录07</span></dd>
        <dd><span>导航目录08</span></dd>
      </dl>
    </li>
    <li class="nav_li">
      <dl>
        <dt><span>教学资源</span></dt>
        <dd><span>导航目录01</span></dd>
        <dd><span>导航目录02</span></dd>
        <dd><span>导航目录03</span></dd>
        <dd><span>导航目录04</span></dd>
        <dd><span>导航目录05</span></dd>
        <dd><span>导航目录06</span></dd>
        <dd><span>导航目录07</span></dd>
        <dd><span>导航目录07</span></dd>
        <dd><span>导航目录07</span></dd>
        <dd><span>导航目录07</span></dd>
        <dd><span>导航目录07</span></dd>
        <dd><span>导航目录07</span></dd>
        <dd><span>导航目录08</span></dd>
      </dl>
    </li>
    <li class="nav_li">
      <dl>
        <dt><span>校园一角</span></dt>
        <dd><span>导航目录01</span></dd>
        <dd><span>导航目录02</span></dd>
        <dd><span>导航目录03</span></dd>
        <dd><span>导航目录04</span></dd>
        <dd><span>导航目录05</span></dd>
        <dd><span>导航目录06</span></dd>
        <dd><span>导航目录07</span></dd>
        <dd><span>导航目录08</span></dd>
      </dl>
    </li>
    <li class="nav_li">
      <dl>
        <dt><span>就业信息</span></dt>
        <dd><span>导航目录01</span></dd>
        <dd><span>导航目录02</span></dd>
        <dd><span>导航目录06</span></dd>
        <dd><span>导航目录07</span></dd>
        <dd><span>导航目录08</span></dd>
      </dl>
    </li>
    <li class="nav_li">
      <dl>
        <dt><span>科研管理</span></dt>
        <dd><span>导航目录01</span></dd>
        <dd><span>导航目录02</span></dd>
        <dd><span>导航目录02</span></dd>
        <dd><span>导航目录02</span></dd>
        <dd><span>导航目录02</span></dd>
        <dd><span>导航目录03</span></dd>
        <dd><span>导航目录04</span></dd>
        <dd><span>导航目录05</span></dd>
        <dd><span>导航目录06</span></dd>
        <dd><span>导航目录07</span></dd>
        <dd><span>导航目录08</span></dd>
      </dl>
    </li>
    <li class="nav_li">
      <dl>
        <dt><span>优秀学员</span></dt>
        <dd><span>导航目录01</span></dd>
        <dd><span>导航目录02</span></dd>
        <dd><span>导航目录03</span></dd>
        <dd><span>导航目录04</span></dd>
        <dd><span>导航目录05</span></dd>
        <dd><span>导航目录05</span></dd>
        <dd><span>导航目录05</span></dd>
        <dd><span>导航目录05</span></dd>
        <dd><span>导航目录05</span></dd>
        <dd><span>导航目录05</span></dd>
        <dd><span>导航目录05</span></dd>
        <dd><span>导航目录05</span></dd>
        <dd><span>导航目录06</span></dd>
        <dd><span>导航目录07</span></dd>
        <dd><span>导航目录08</span></dd>
      </dl>
    </li>
    <li class="nav_li">
      <dl>
        <dt><span>优秀教师</span></dt>
        <dd><span>导航目录01</span></dd>
        <dd><span>导航目录02</span></dd>
        <dd><span>导航目录03</span></dd>
        <dd><span>导航目录04</span></dd>
        <dd><span>导航目录05</span></dd>
        <dd><span>导航目录05</span></dd>
        <dd><span>导航目录06</span></dd>
        <dd><span>导航目录07</span></dd>
        <dd><span>导航目录08</span></dd>
      </dl>
    </li>
    <li class="nav_li">
      <dl>
        <dt><span>课程大纲</span></dt>
        <dd><span>导航目录01</span></dd>
        <dd><span>导航目录02</span></dd>
        <dd><span>导航目录03</span></dd>
        <dd><span>导航目录06</span></dd>
        <dd><span>导航目录07</span></dd>
        <dd><span>导航目录08</span></dd>
      </dl>
    </li>
    <li class="clear"></li>
  </ul>
</body>
</html>